/**
  * Author: Mei
  * Date: 2020-11-21 16:12
  * Description: 
  *
  */
#include <iostream>
#include <cstring>

using namespace std;

class Foo {
public:
    int *p;

    Foo(int x) {
        p = new int(x);
    }

    Foo(Foo &&r) {
        p = r.p;
        r.p = nullptr;
    }
    //Foo(const Foo &r) {
    //    p = new int;
    //    *p = *(r.p);
    //}

    ~Foo() {
        if (p != NULL) {
            delete (p);
        }
    }

    void show() {
        cout << p << " " << *p << endl;
    }
};
Foo func() {
    Foo foof(100);
    return foof;
}
int main() {
    Foo foo1(4);
    Foo foo2(func());
    foo1.show();
    foo2.show();


    return 0;
}